home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue28 / clinic / APPLNCHU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-11-05  |  1.0 KB  |  55 lines

  1. unit AppLnchU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Button1: TButton;
  12.     Button2: TButton;
  13.     Edit1: TEdit;
  14.     procedure Button1Click(Sender: TObject);
  15.     procedure Button2Click(Sender: TObject);
  16.   private
  17.     { Private declarations }
  18.   public
  19.     { Public declarations }
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. var
  30.   PI: TProcessInformation;
  31.  
  32. procedure TForm1.Button1Click(Sender: TObject);
  33. var
  34.   SI: TStartupInfo;
  35. begin
  36.   GetStartupInfo(SI);
  37.   Win32Check(CreateProcess(nil, PChar(Edit1.Text), nil, nil,
  38.     False, 0, nil, nil, SI, PI));
  39.   WaitForInputIdle(PI.hProcess, Infinite);
  40.   Button2.Enabled := True
  41. end;
  42.  
  43. procedure TForm1.Button2Click(Sender: TObject);
  44. const
  45.   Msgs: array[Boolean] of String =
  46.     ('Stopped', 'Still running');
  47. var
  48.   Flag: Boolean;
  49. begin
  50.   Flag := WaitForSingleObject(PI.hProcess, 1) = Wait_TimeOut;
  51.   ShowMessage(Msgs[Flag])
  52. end;
  53.  
  54. end.
  55.